<html>
<head>
  <meta charset="utf-8">
  <#assign base=request.contextPath  />
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <title>宝宝护理</title>
  <link rel="stylesheet" href="${base}/js/layui/css/layui.css?t=1534970980648" media="all">
 <script type="text/javascript" src="${base}/js/zhang.js"></script>
   <style type="text/css">
    	form{
    		padding: 20px;
    	}
    	.layui-btn-radius{
        			border-radius: 5px;
        		}
        		</style>
    </style>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
	  <legend>宝宝信息</legend>
	</fieldset>

	<div class="demoTable"style="padding:15px;">
         <button class="layui-btn layui-btn-radius" id="btn2" data-method="offset" type="button" style="background-color: #0092EF;">录入宝宝信息</button>
        <div class="layui-inline layui-form" style="float:right;">
        <div class="layui-input-inline">
            <select name="interest"  id="sech"  lay-search="">
                <option value="room_name">房间号</option>
                <option value="name">姓名</option>
                <option value="sex">性别</option>
                <option value="heightr">身高</option>
                <option value="weigth">体重</option>
                <option value="babynursery">育婴师</option>
                <option value="people">责任护士</option>
                <option value="ofnursing">护理类型</option>
                <option value="eatmink">吃奶</option>
                <option value="foodd">喂养类型</option>
                <option value="temper">体温</option>
                <option value="head">头围</option>
                <option value="jaundice">黄疸值</option>
                <option value="redbuttocks">是否红臀</option>
                <option value="day">入住天数</option>
                <option value="touch">抚触</option>
                <option value="sleepcondition">睡眠情况</option>
                <option value="shower">洗澡</option>
                <option value="swimming">游泳</option>
                <option value="delivery">分娩方式</option>
                <option value="remarks">备注</option>
            </select>
        </div>
    	  <div class="layui-inline">
    	    <input class="layui-input" name="id" id="demoReload" autocomplete="off">
    	  </div>
    	  <button class="layui-btn layui-btn-radius" id="btn1" data-type="reload" style="background-color: #0092EF;">搜索</button>
       </div>
    </div>
	<table class="layui-hide" id="table_baby" lay-filter="user"></table>
<script type="text/html" id="barDemo">
  <i class="layui-icon layui-icon-edit" lay-event="edit" id="updatebaby" style="font-size: 20px;" ></i>&nbsp;&nbsp;&nbsp;
  <i class="layui-icon layui-icon-delete layui-btn-xs" lay-event="del" id="delectbaby" href="javascript:void(0)"  onclick="delectbaby('{{d.id}}')"  style="font-size: 20px;" ></i>
</script>
<script src="${base}/js/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="${base}/js/ztree/jquery-1.4.4.min.js"></script>
<script src="${base}/js/jquery.min.js"></script>
<script>

layui.use(['form', 'layedit', 'laydate','table'], function(){
  var form = layui.form
  ,$ = layui.jquery
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate
  table = layui.table;
  table.render({
    elem: '#table_baby'
    ,url: '${base}/babyNursing/selectBabyNursing'//数据接口
    ,toolbar: '#toolbarDemo'
        ,defaultToolbar: ['filter', 'print', 'exports']

    ,cols: [[
       {field:'id', title: 'ID',templet:function(val){return val.LAY_INDEX},align:'center',  width:60,fixed: true}
       ,{field:'createTime' ,templet:function(val){
                                        return changeDateFormat(val.createTime);
                                               }, title:'日期时间', align: 'center',width:160}
,{field:'room_name', title: '房间号',align: 'center',width:80}
      ,{field:'name', title: '姓名',align:'center',width:120}
,{field:'sex', title: '性别',align:'center',width:120}
,{field:'babynursery', title: '育婴师', align:'center',width:120}
,{field:'people', title: '责任护士', align:'center',width:120}
,{field:'delivery', title: '分娩方式', align:'center',width:120}
,{field:'day', title: '入住天数', align:'center',width:120}
,{field:'ofnursing', title: '护理类型', align:'center',width:120}
,{field:'foodd', title: '喂养类型', align:'center',width:120}
,{field:'sleepcondition', title: '睡眠情况',align:'center',width:120}
,{field:'heightr', title: '身高', align:'center',width:120}
,{field:'weigth', title: '体重',align: 'center',width:120}
,{field:'head', title: '头围', align:'center',width:120}
,{field:'temper', title: '体温', align:'center',width:120}
,{field:'redbuttocks', title: '是否红臀',align:'center',width:120}
,{field:'jaundice', title: '黄疸值',align:'center',width:120}



,{field:'eatmink', title: '吃奶',align:'center',width:120}
,{field:'touch', title: '抚触', align:'center',width:120}
,{field:'shower', title: '洗澡', align:'center',width:120}
,{field:'swimming', title: '游泳', align:'center',width:120}
,{field:'remarks2', title: '备注', align:'center',width:150}
      //,{field:'umbilicalcord', title: '脐带护理', align:'center',width:120}
      //,{field:'shit', title: '大便情况', align:'center',width:120}
      //,{field:'umbilicalTime',templet:function(val){
      //                            return GetDateByShiJianChuo(val.umbilicalTime);
      //                        }, title: '脐带消毒时间', align:'center',width:60}
     // ,{field:'umbilicalCord', title: '脐带脱落情况', align:'center',width:60}
      //,{field:'feedTime',templet:function(val){
      //                       return GetDateByShiJianChuo(val.feedTime);
      //                   }, title: '喂养时间', align:'center',width:60}
      //,{field:'feedVolume', title: '喂养奶量', align:'center',width:60}
      //,{field:'bottle', title: '奶瓶消毒', align:'center',width:60}
      //,{field:'shitTime',templet:function(val){
      //                       return GetDateByShiJianChuo(val.shitTime);
      //                   }, title: '大便观察时间', align:'center',width:60}
      //,{field:'shitChromatic', title: '大便观察色状', align:'center',width:60}
     // ,{field:'milkTime',templet:function(val){
     //                        return GetDateByShiJianChuo(val.milkTime);
     //                    } ,title: '挤奶时间', align:'center',width:60}
     // ,{field:'milkVolume', title: '挤奶奶量', align:'center',width:60}
//,{field:'urineTime',templet:function(val){
 //                      return GetDateByShiJianChuo(val.urineTime);
  //                 } ,title: '小便时间', align:'center',width:60}
//,{field:'urineChromatic', title: '小便色状', align:'center',width:60}
      ,{fixed: 'right', title:'操作', toolbar: '#barDemo',width:120, align: 'center'}
    ]]
    ,id: 'testReload'
    ,page: {
           layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
           ,theme: '#0092EF'
           ,limit:20
         }
    ,height:500
     ,done: function(res, curr, count){
this.where={};
     }
  });


//搜索
  $('#btn1').on('click', function(){
    var sechLin=$("#sech").val();
     var sechData=$("#demoReload").val();
   var whereData={};
   whereData.lin=sechLin;
   whereData.data=Trim(sechData);
   whereData.page=1;
   whereData.limit=10;

     var table = layui.table;
                  //表刷新方法
                  table.reload('testReload', {
                      url: '${base}/babyNursing/selectBabyNursing'
                      ,where: whereData
                  });

  });
  var active = {
    	offset: function(othis){
    	  var type = othis.data('type')
    	  ,text = othis.text();
		  layer.open({
		  type: 2,
		  title: '录入宝宝信息',
		  shadeClose:false ,
		  offset: 't',
          area:['100%','100%'],
		  content: '${base}/babyNursing/baby_add',
		    success: function (layero, index) {
                var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();

           }
		});
	}
  };
layui.form.on('select()', function(data){
 $("#demoReload").val("")
});
   $('#btn2').on('click', function(){
    var othis = $(this), method = othis.data('method');
    active[method] ? active[method].call(this, othis) : '';
  });
//编辑弹出层
    table.on('tool(user)', function(obj){
      var layEvent = obj.event;
      if(layEvent=="edit"){
                 var data = obj.data;
                  //示范一个公告层
                  layer.open({
                      type: 2,
                      title: '修改宝宝信息',
                      shadeClose:false ,
                      offset: 't',
                       area:['100%','100%'],
                      content: '${base}/babyNursing/baby_edit',
                      success: function (layero, index) {
                          var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
//房间
  iframeWin.$("#homeId").val(data.roomId)
//姓名
  iframeWin.$("#name").val(data.name)
//性别
  //iframeWin.$("#name").val(data.name)
//黄疸值
  iframeWin.$("#jaundice").val(data.jaundice)
//是否红臀
  iframeWin.$("#Redbuttocks").val(data.redbuttocks)
//吃奶
  iframeWin.$("#Eatmink").val(data.eatmink)
//睡眠情况v
  iframeWin.$("#Sleepcondition").val(data.sleepcondition)
//脐带护理
  //iframeWin.$("#umbilicalcord").val(data.umbilicalcord)
//责任护士
  iframeWin.$("#people").val(data.people)
//育婴师
  iframeWin.$("#babynursery").val(data.babynursery)
//入住天数
  iframeWin.$("#day").val(data.day)
//护理类型
  iframeWin.$("#ofnursing").val(data.ofnursing)

//身高
  iframeWin.$("#heightr").val(data.heightr)
//头围
  iframeWin.$("#head").val(data.head)
//体重
  iframeWin.$("#weigth").val(data.weigth)
//体温
  iframeWin.$("#temper").val(data.temper)
//喂养类型
  iframeWin.$("#foodd").val(data.foodd)
//洗澡
  iframeWin.$("#shower").val(data.shower)

//抚触
  iframeWin.$("#touch").val(data.touch)
//脐带消毒时间
  //iframeWin.$("#date").val(GetDateByShiJianChuo(data.umbilicalTime))
//脐带脱落情况
  //iframeWin.$("#umbilicalCord").val(data.umbilicalCord)
//喂养时间
  //iframeWin.$("#date1").val(GetDateByShiJianChuo(data.feedTime))
//喂养奶量
  //iframeWin.$("#feedVolume").val(data.feedVolume)
//奶瓶消毒
  //iframeWin.$("#bottle").val(data.bottle)
//大便观察时间
  //iframeWin.$("#date2").val(GetDateByShiJianChuo(data.shitTime))
//大便观察色状
  //iframeWin.$("#shitChromatic").val(data.shitChromatic)
//挤奶时间
  //iframeWin.$("#date3").val(GetDateByShiJianChuo(data.milkTime))
//挤奶奶量
  iframeWin.$("#milkVolume").val(data.milkVolume)
//游泳
  iframeWin.$("#swimming").val(data.swimming)
//护理类型
  //iframeWin.$("#ofnursing").val(data.ofnursing)
//分娩方式
  iframeWin.$("#delivery").val(data.delivery)
//小便时间
  //iframeWin.$("#date4").val(GetDateByShiJianChuo(data.urineTime))
//小便色状
  //iframeWin.$("#urineChromatic").val(data.urineChromatic)
//备注
  iframeWin.$("#remarks2").val(data.remarks2)
//id
  iframeWin.$("#id").val(data.id)








                         /* iframeWin.$("#jaundice").val(data.jaundice)

                          iframeWin.$("#username").val(data.username)
                          iframeWin.$("#eczema").val(data.eczema)
                          iframeWin.$("#Hotrash").val(data.hotrash)
                          iframeWin.$("#Eatmink").val(data.eatmink)
                          iframeWin.$("#Redbuttocks").val(data.redbuttocks)
                          iframeWin.$("#umbilicalcord").val(data.umbilicalcord)
                          iframeWin.$("#Sleepcondition").val(data.sleepcondition)
                          iframeWin.$("#people").val(data.people)
                          iframeWin.$("#nursery").val(data.nursery)
                          iframeWin.$("#days").val(data.days)
                          iframeWin.$("#heightr").val(data.heightr)
                          iframeWin.$("#head").val(data.head)
                          iframeWin.$("#temper").val(data.temper)
                          iframeWin.$("#foodd").val(data.foodd)
                          iframeWin.$("#shit").val(data.shit)
                          iframeWin.$("#shower").val(data.shower)
                          iframeWin.$("#touch").val(data.touch)
                          iframeWin.$("#remarks").val(data.remarks)
                          iframeWin.$("#weigth").val(data.weigth)
                          iframeWin.$("#babyId").val(data.id)*/
                           setTimeout(function(){
                              iframeWin.$("#home_id option[value='"+data.roomId+"']").attr("selected", "selected");
                              iframeWin.layui.form.render('select')
                                },100)
                          //单选框
                          if(data.sex=='男'){
                              iframeWin.$("#man").attr("checked",true)
                              var form = iframeWin.layui.form;
                              form.render('radio'); //更新全部
                          }else{
                              iframeWin.$("#wuman").attr("checked",true)
                              var form = iframeWin.layui.form;
                              form.render('radio'); //更新全部
                          }
                      }
                  });
      }
    });
});

function delectbaby(id){
layer.confirm('真的要删除吗?', function(index){
 $.ajax({
    type:"POST",
       url:"${base}/babyNursing/delectBaby",
       data:{"id":id},
           success : function(data){
           var table = layui.table;
            //表刷新方法
              table.reload('testReload', {
                   url: '${base}/babyNursing/selectBabyNursing'
                      ,where: {} //设定异步数据接口的额外参数
                                  });
                                    layer.close(index);
                       }
                 });

} );
            }
	//键盘事件
    $("body").bind("keydown",function(e){
        // 兼容FF和IE和Opera
        var theEvent = e || window.event;
        var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
        if (code == 13) {
            //回车执行查询
            $("#btn1").click();
        }
    });
</script>

</body>
</html>